package cn.net.cfss.fgbp.face.manage.vo;

import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;

/**
 * @author wutao
 * @version 1.0
 * @date 2021/3/12 16:31
 */
public class MultipartFileResource implements MultipartFile {

    byte[] b = new byte[0];

    public MultipartFileResource () {

    }

    @Override
    public String getName() {
        return null;
    }

    @Override
    public String getOriginalFilename() {
        return null;
    }

    @Override
    public String getContentType() {
        return null;
    }

    @Override
    public boolean isEmpty() {
        return false;
    }

    @Override
    public long getSize() {
        return b != null ? b.length : 0;
    }

    @Override
    public byte[] getBytes() throws IOException {
        return b != null ? b : new byte[0];
    }

    @Override
    public InputStream getInputStream() throws IOException {
        return new ByteArrayInputStream(b);
    }

    @Override
    public void transferTo(File file) throws IOException, IllegalStateException {

    }
}
